package com.yufuchang;

import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.WebRequest;

import java.util.Map;

/**
 * Created by yufuchang on 2020/9/4.
 */
//@Component
public class MyErrorAttribute extends DefaultErrorAttributes{

    @Override
    public Map<String, Object> getErrorAttributes(WebRequest webRequest, ErrorAttributeOptions options) {
        Map<String,Object> errorAttributes = super.getErrorAttributes(webRequest, options);
        errorAttributes.put("msg","异常");
        errorAttributes.remove("error");
        return errorAttributes;
    }
}
